package me.hellp.helloworld.design.iterator;

/**
 * 具体迭代器角色(Concrete Iterator)
 * 
 * @author linxm
 *
 */
public class MyConcreteIterator implements MyIterator {
	private MyConcreteAggregate list = null;
	private int index;

	public MyConcreteIterator(MyConcreteAggregate list) {
		super();
		this.list = list;
	}

	@Override
	public boolean hasNext() {
		if (index >= list.getSize()) {
			return false;
		} else {
			return true;
		}
	}

	@Override
	public Object next() {
		Object object = list.get(index);
		index++;
		return object;
	}

}
